package parser.dao;

import utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class RelationDao {
    public static boolean insertRelation(String sourceClass, String destinationClass, String relationType) {
        boolean result = false;
        Connection conn = null;
        PreparedStatement stm = null;
        try {
            conn = JDBCUtils.getConnection();
            stm = conn.prepareStatement("insert into source_code_info(SourceClass,DestinationClass,RelationType) values(?,?,?);");
            stm.setString(1, sourceClass);// 设置字符串值
            stm.setString(2, destinationClass);
            stm.setString(3, relationType);
            int i = stm.executeUpdate();
            if (i != 0)
                result = true;
            stm.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.close(null, stm, conn);
        }
        return result;
    }
}
